<template>
  <uni-nav-bar title="新增授权" left-icon="left" @clickLeft="navBack" :fixed="true" statusBar></uni-nav-bar>
  <image :src="`${addauthor}`" style="width: 100%; height: 94vh" mode="aspectFill" v-if="addauthor" :show-menu-by-longpress="true"></image>
  <webWechat :path="path"></webWechat>
</template>

<script setup lang="ts">
import { shareUserInfo } from '@/gql/user';
import { getDriverID } from '@/stores/driverID';
import { navBack } from '@/utils/navigator';
import { showLoading } from '@/utils/prompt';
import webWechat from '@c/pobulic/webWechat.vue';
import { toPublish } from '@mqtt';
import { ref } from 'vue';
// static
const driver_id = getDriverID();
const addauthor = ref('');
const path=ref('')
init();
function init() {
  showLoading('加载中');
  const payload = {
    query: shareUserInfo,
    variables: { driver_id },
  };
  toPublish('ql/driver/addAothor', payload, (obj: any) => {
    const { data } = obj;
    const key=Date.now().toString().substr(0,10)
	  path.value=`https://wx.anlan.tech/#/?type=account&from_driver_id=${driver_id}&key=${key}`
    addauthor.value = data.driver_info.em_qrcode;
  });
}
</script>

<style></style>
